package com.ks.repair.controller;


import com.ks.core.base._ControllerBase;
import com.ks.core.core.Result;
import com.ks.core.dto.OperateBase;
import com.ks.core.dto.SearchCriteriaBase;
import com.ks.repair.controller.dto.RepairBillInfoRequest;
import com.ks.repair.controller.dto.RepairBillRequest;
import com.ks.repair.entity.*;
import com.ks.repair.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 报修-会员填写的报修单 前端控制器
 * </p>
 *
 * @author kingdee123
 * @since 2020-12-15
 */
@RestController
@RequestMapping("/bRepairBillApp")
@Api(value = "应用端", description = "应用端")
public class BRepairAppController extends _ControllerBase {

    @Autowired
    private IBRepairBillService bRepairBillService;

    @Autowired
    private IBRepairClassService bRepairClassService;

    @Autowired
    private IBRepairBillTemplateService bRepairBillTemplateService;

    @Autowired
    private IBRepairFeesService bRepairFeesService;


    @PostMapping("/addRepair")
    @ApiOperation(value = "报修提报接口", notes = "报修提报接口")
    public Object addRepair(@RequestBody RepairBillInfoRequest repairBillInfoRequest) {
        int i = bRepairBillService.addRepairBill(getContext(),repairBillInfoRequest.getBRepairBill(),repairBillInfoRequest.getBRepairBillExList());
        return Result.success(i);
    }

    @PostMapping("/getRepairCustom")
    @ApiOperation(value = "报修单自定义模板获取接口", notes = "报修单自定义模板获取接口")
    public Object getRepairCustom(@RequestBody SearchCriteriaBase searchCriteriaBase) {
        Map<String,Object>  resultMap = bRepairBillTemplateService.getRepairCustom(getContext(),searchCriteriaBase);
        return Result.success(resultMap);
    }


    @PostMapping("/selectRepairClass")
    @ApiOperation(value = "服务种类列表查询接口",notes = "服务种类列表查询接口")
    public Object selectRepairClass (@RequestBody SearchCriteriaBase searchCriteriaBase){
        Map<String,Object> resultMap =bRepairClassService.selectRepairClass(getContext(),searchCriteriaBase);
        return Result.success(resultMap);
    }


    @PostMapping("/selectMemberRepair")
    @ApiOperation(value = "会员报修记录查询接口",notes = "会员报修记录查询接口")
    public Object selectMemberRepair (@RequestBody SearchCriteriaBase searchCriteriaBase){
        Map<String,Object> resultMap =bRepairBillService.selectRepairList(getContext(),searchCriteriaBase);
        return Result.success(resultMap);
    }


    @PostMapping("/selectRepairFees")
    @ApiOperation(value = "服务收费项列表查询接口",notes = "服务收费项列表查询接口")
    public Object selectRepairFees (@RequestBody SearchCriteriaBase searchCriteriaBase){
        Map<String,Object> resultMap =bRepairFeesService.selectRepairFees(getContext(),searchCriteriaBase);
        return Result.success(resultMap);
    }


    @PostMapping("/selectRepairTemplate")
    @ApiOperation(value = "报修单模板字段列表查询接口",notes = "报修单模板字段列表查询接口")
    public Object selectRepairTemplate (@RequestBody SearchCriteriaBase searchCriteriaBase){
        Map<String,Object> resultMap =bRepairBillTemplateService.selectRepairTemplate(getContext(),searchCriteriaBase);
        return Result.success(resultMap);
    }

    @PostMapping("/addRepairTemplate")
    @ApiOperation(value = "报修单模板字段添加接口", notes = "报修单模板字段添加接口")
    public Object addRepairTemplate(@RequestBody BRepairBillTemplate bRepairBillTemplate) {
        int i = bRepairBillTemplateService.addRepairTemplate(getContext(),bRepairBillTemplate);
        return Result.success(i);
    }


    @PostMapping("/updateRepairTemplate")
    @ApiOperation(value = "报修单模板字段修改接口", notes = "报修单模板字段修改接口")
    public Object updateRepairTemplate(@RequestBody BRepairBillTemplate bRepairBillTemplate) {
        int i = bRepairBillTemplateService.updateRepairTemplate(getContext(),bRepairBillTemplate);
        return Result.success(i);
    }


    @PostMapping("/deleteRepairTemplate")
    @ApiOperation(value = "报修单模板字段删除接口", notes = "报修单模板字段删除接口")
    public Object deleteRepairTemplate(@RequestBody OperateBase operateBase) {
        List i = bRepairBillTemplateService.deleteRepairTemplate(getContext(),operateBase);
        return Result.success(i);
    }


    @PostMapping("/addRepairFees")
    @ApiOperation(value = "服务收费项添加接口", notes = "服务收费项添加接口")
    public Object addRepairFees(@RequestBody BRepairFees bRepairFees) {
        int i = bRepairFeesService.addRepairFees(getContext(),bRepairFees);
        return Result.success(i);
    }


    @PostMapping("/updateRepairFees")
    @ApiOperation(value = "服务收费项修改接口", notes = "服务收费项修改接口")
    public Object updateRepairFees(@RequestBody BRepairFees bRepairFees) {
        int i = bRepairFeesService.updateRepairFees(getContext(),bRepairFees);
        return Result.success(i);
    }


    @PostMapping("/deleteRepairFees")
    @ApiOperation(value = "服务收费项删除接口", notes = "服务收费项删除接口")
    public Object deleteRepairFees(@RequestBody OperateBase operateBase) {
        List i = bRepairFeesService.deleteRepairFees(getContext(),operateBase);
        return Result.success(i);
    }


    @PostMapping("/selectRepairBillList")
    @ApiOperation(value = "报修单列表查询接口",notes = "报修单列表查询接口")
    public Object selectRepairBillList (@RequestBody SearchCriteriaBase searchCriteriaBase){
        Map<String,Object> resultMap =bRepairBillService.selectRepairBillList(getContext(),searchCriteriaBase);
        return Result.success(resultMap);
    }

    @PostMapping("/selectRepairBill")
    @ApiOperation(value = "报修单详情查询接口",notes = "报修单详情查询接口")
    public Object selectRepairBill (@RequestBody RepairBillRequest repairBillRequest){
        Map<String,Object> resultMap =bRepairBillService.selectRepairBill(getContext(),repairBillRequest);
        return Result.success(resultMap);
    }


    @PostMapping("/delRepairBillList")
    @ApiOperation(value = "报修单列表删除接口",notes = "报修单列表删除接口")
    public Object delRepairBillList (@RequestBody OperateBase operateBase){
        int resultMap =bRepairBillService.delRepairBillList(getContext(),operateBase);
        return Result.success(resultMap);
    }


    @PostMapping("/addRepairNo")
    @ApiOperation(value = "生成工单号",notes = "生成工单号")
    public Object addRepairNo (@RequestBody OperateBase operateBase){
        int resultMap =bRepairBillService.addRepairNo(getContext(),operateBase);
        return Result.success(resultMap);
    }
}
